﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;

namespace uLib.Helper
{
    public class MailHelper
    {
        public void sendMail(string fromMail, string toMail, string subject, string message, string server, int port, string user, string password)
        {
            MailMessage Email = new MailMessage();

            Email.From = new MailAddress(fromMail);
            Email.To.Add(toMail);
            Email.Subject = subject;

            Email.Body = message;

            SmtpClient MailClient = new SmtpClient(server, port);

            if (user.Length > 0 && user != string.Empty)
            {
                MailClient.Credentials = new System.Net.NetworkCredential(user, password);
            }
            MailClient.Send(Email);
        }
    }
}
